<html>
<body>
<?php echo "<h3>Torrent Search</h3>";?>
<form method ="GET" >
<input type="text" name="search" size="30">
<input type ="submit" name="searchbutton" value="Search">
</form>
<?php
if($_GET['search'] !=""){
	$con = mysql_connect("sql212.xtreemhost.com","xth_8628058","thinkcom");
	if (!$con)
	  {
	  die('Could not connect: ' . mysql_error());
	  }

	mysql_select_db("xth_8628058_ikbhal", $con);
    $keyword =$_GET['search'];
	$sql ="SELECT * FROM torrent where lower(title) like '%". strtolower($keyword)."%'";
	$column_names = "seeds desc";
	$sql = $sql ." order by ". $column_names;
	$start =0 ;
	$end =30;
	//$sql = $sql ." limit $start,$end ";
	$result = mysql_query($sql);
	echo "sql:".$sql."<br>";
    echo "<h3>Search results</h3>";
	echo "<table><tr><td>title</td><td>seeds</td><td>leaches</td><td>addedDate</td></tr>";
	while($row = mysql_fetch_array($result))  {
	    echo "<tr><td><a href='".$row['url']."'>".$row['title'] ."</a></td><td>".$row['seeds'] ."</td><td>".$row['leaches']. "</td><td>".$row['addedDate'] ."</td></tr>";
	  
	  }
	  echo "</table>" ;

	mysql_close($con);
}
?> 
</body>
</html>